package com.sxj.corejava.code07_面向对象.继承;

/**
 * @author 石小俊
 * @date 2024年03月19日 18:31
 */
public class Person {

    private String name;
    private int age;
    private String gender;

    public void show() {
        System.out.println("姓名:" + name + ",年龄:" + age + ",性别:" + gender);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }
}

class Man extends Person {
    private double salary;

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public void work() {
        System.out.println("我是一个男人,需要赚钱养家,每个月能赚" + salary + "元");
    }
}

class WoMan extends Person {
    private int appearance;

    public int getAppearance() {
        return appearance;
    }

    public void setAppearance(int appearance) {
        this.appearance = appearance;
    }

    public void shopping() {
        System.out.println("作为一个颜值达到" + appearance + "女士,只需要负责买买买就行了");
    }
}

class TestPerson {
    public static void main(String[] args) {
        Person person = new Person();
        Man man = new Man();
        // man.name = "admin";
        man.setName("admin");
        man.setGender("男");
        man.setAge(20);
        man.show();
        man.setSalary(18000);
        man.work();
        man.toString();

        WoMan woMan = new WoMan();
        woMan.setName("alice");
        woMan.setGender("女");
        woMan.setAge(18);
        woMan.show();
        woMan.setAppearance(95);
        woMan.shopping();

        // 当一个类没有直接继承任何类时,其仍然有父类
        // 所有类的父类均为Object
        SomeClass sc = new SomeClass();
        System.out.println(sc.toString());
        System.out.println(sc.hashCode());

        Son son = new Son();
        son.setName("admin");
        son.setSalary(8000);
        son.show();
        son.work();
    }
}

// 在代码逻辑上是可以实现的,但是在现实逻辑中不合适
// 实际开发中,不允许出现
class Cat extends Person{

}

class SomeClass{

}

class Son extends Man{

}